package com.bml.architect.spring.convert.jdk;

import com.bml.architect.spring.service.User;

import java.beans.PropertyEditor;
import java.beans.PropertyEditorSupport;
import java.util.Random;

/**
 * jdk自带的类型转换
 */
public class StringToUserPropertyEditor extends PropertyEditorSupport implements PropertyEditor {


    @Override
    public void setAsText(String text) throws IllegalArgumentException {

        User user = new User();
        user.setId(new Random().nextInt(10));
        user.setName(text);
        this.setValue(user);
    }
}
